home *** CD-ROM | disk | FTP | other *** search
- #include <IOKit/IOLib.h>
- #include "HelloIOKitwithPowerManagement.h"
- extern "C" {
- #include <pexpert/pexpert.h>
- }
- // Define my superclass
- #define super IOService
- // REQUIRED! This macro defines the class's constructors, destructors,
- // and several other methods I/O Kit requires. Do NOT use super as the
- // second parameter. You must use the literal name of the superclass.
- OSDefineMetaClassAndStructors(com_DTS_driver_HelloIOKitwithPowerManagement, IOService)
-
- bool com_DTS_driver_HelloIOKitwithPowerManagement::init(OSDictionary *dict)
- {
- bool res = super::init(dict);
- IOLog("%s:DTS Sample Code\n",getName());
- if (res = true)
- IOLog("%s:Initializing\n",getName());
- else
- IOLog("%s:No Initialization\n",getName());
- return true;
- }
- void com_DTS_driver_HelloIOKitwithPowerManagement::free(void)
- {
- IOLog("%s:Freeing\n",getName());
- super::free();
- }
- IOService *com_DTS_driver_HelloIOKitwithPowerManagement::probe(IOService *provider,
- SInt32 *score)
- {
- IOService *res = super::probe(provider, score);
- IOLog("%s:Probing\n",getName());
- return res;
- }
- bool com_DTS_driver_HelloIOKitwithPowerManagement::start(IOService *provider)
- {
- IOReturn myValue;
- bool res = super::start(provider);
- IOLog("%s:Starting\n",getName());
- // initialize superclass variables from IOService.h
- PMinit();
- // register as controlling driver from IOService.h
- myValue = registerPowerDriver(this, (IOPMPowerState *) ourPowerStates,
- kNumDTSStates );
- if (myValue != kIOReturnSuccess) {
- IOLog("%s: Failed to registerPowerDriver.\n", getName());
- }
- // join the tree from IOService.h
- provider->joinPMtree(this);
-
- return res;
- }
- void com_DTS_driver_HelloIOKitwithPowerManagement::stop(IOService *provider)
- {
- IOLog("%s:Stopping\n",getName());
- PMstop();
- super::stop(provider);
- }
- // set your device power on/off logic here
- IOReturn com_DTS_driver_HelloIOKitwithPowerManagement::setPowerState(unsigned long whatState, IOService* dontCare){
- IOLog("%s:PowerManagement setting power state:%lu\n",getName(), whatState);
- return IOPMAckImplied;
- }